// result_lab_1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;
class my_class
{
    protected:
    double  r;
    double angle_Y;
    double angle_X;

    public:
    my_class()
    {
        r = 0;
        angle_Y = 0;
        angle_X = 0;

    }
    my_class(double R, double angle)
    {
        r = R;
        angle_Y = angle;
        angle_X = 0;
        
    }
    double get_my_int()
    {
        return r;
    }
    double get_angle_X()
    {
        return angle_X;
    }
    double get_angle_Y()
    {
        return angle_Y;
    }
    
    void set_r(double tmp)
    {
        r = tmp;
    }
    
    void set_angle_X(double tmp)
    {
        angle_X = tmp;
    }
    void set_angle_Y(double tmp)
    {
        angle_Y = tmp;
    }
    void calc_Spherical_coordinates()
    {
        double x = r*cos(angle_Y*M_PI / 180)*sin(angle_X*M_PI / 180);
        double y = r*cos(angle_Y*M_PI / 180);
        double z = r*cos(angle_X*M_PI / 180)*sin(angle_Y*M_PI / 180);
        cout << x << "  " << y << "  " << z << endl;
    }
   
};
class polar_coordinates:public my_class
{
    public:
    polar_coordinates(double R, double angle) : my_class(R, angle)
    {

    }
    void calc_polar_coordinates()
    {
        double x = r*cos(angle_Y*M_PI / 180);
        double y = r*sin(angle_Y*M_PI / 180);
        cout<<"x = " << x << "\t y = " << y << endl;
    }
};
int main()
{
    double r;
    double angle_Y;
    double angle_X;
    my_class its_my;
    cin >> r >> angle_X >> angle_Y;
    do
    {
        if (angle_Y > 360 || angle_Y < 0)
        {
            cin >> angle_Y;
            
        }
        if (angle_X > 360 || angle_X<0)
        {
            cin >> angle_X;
            
            
        }
        if (angle_Y < 360 && angle_Y > 0&&angle_X < 360 && angle_X > 0)
        {
            
                break;
            
        }
        
    }
    while (true);
    its_my.set_angle_X(angle_X);
    its_my.set_angle_Y(angle_Y); 
    its_my.set_r(r);
    cout << its_my.get_angle_X() <<"\t"<< its_my.get_angle_Y()<<"\t" << its_my.get_my_int() << endl;
    its_my.calc_Spherical_coordinates();
    cin >> r >> angle_Y;
    polar_coordinates polar(r, angle_Y);
    polar.calc_polar_coordinates();
    system("pause");
    return 0;
}

